package com.mszlu.blog.controller;

import com.mszlu.blog.service.CommentsService;
import com.mszlu.blog.vo.Result;
import com.mszlu.blog.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.mszlu.blog.controller
 * @ClassName: CommentsController
 * @Author: 陈威
 * @CreateTime: 2021/9/2 15:54
 * @Description:
 */
@RestController
@RequestMapping("comments")
public class CommentsController {

    @Autowired
    CommentsService commentsService;


    //加载评论信息
    @GetMapping("article/{id}")
    public Result comments(@PathVariable("id")Long articleId){

        return commentsService.commentsByArticleId(articleId);
    }

    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentsService.comment(commentParam);

    }

    //查询全部评论
    @PostMapping("/commentAll")
    public Result commentAll(@RequestBody CommentParam commentParam){
        return commentsService.commentAll(commentParam);

    }

}